// Basic interactions for prototype
document.addEventListener('DOMContentLoaded', function() {
  // Handle tab switching
  const tabItems = document.querySelectorAll('.tab-item');
  if (tabItems) {
    tabItems.forEach(tab => {
      tab.addEventListener('click', function() {
        tabItems.forEach(t => t.classList.remove('active'));
        this.classList.add('active');
      });
    });
  }
  
  // Handle toggle switches
  const toggles = document.querySelectorAll('.switch input');
  if (toggles) {
    toggles.forEach(toggle => {
      toggle.addEventListener('change', function() {
        // In a real app, this would save the toggle state
        console.log('Toggle changed:', this.checked);
      });
    });
  }
  
  // Handle form submissions
  const forms = document.querySelectorAll('form');
  if (forms) {
    forms.forEach(form => {
      form.addEventListener('submit', function(e) {
        e.preventDefault();
        // In a real app, this would submit the form data
        console.log('Form submitted');
        
        // If on login page, redirect to dashboard
        if (form.id === 'loginForm' || form.id === 'signupForm') {
          window.location.href = 'dashboard.html';
        }
        
        // If on add habit page, redirect to dashboard
        if (form.id === 'addHabitForm') {
          window.location.href = 'dashboard.html';
        }
      });
    });
  }
  
  // Handle navigation buttons
  const navButtons = document.querySelectorAll('[data-nav]');
  if (navButtons) {
    navButtons.forEach(button => {
      button.addEventListener('click', function() {
        const target = this.getAttribute('data-nav');
        if (target) {
          window.location.href = target;
        }
      });
    });
  }
});
